//
//  MemViewController.m
//  轮胎商城
//
//  Created by 张晋磊 on 2017/3/21.
//  Copyright © 2017年 张晋磊. All rights reserved.
//

#import "MemViewController.h"


@interface MemViewController ()<UITableViewDelegate,UITableViewDataSource,UIScrollViewDelegate>

@property (nonatomic,retain) UITableView *table;
@property (nonatomic,retain) UIImageView *img;
@property (nonatomic,retain) UIButton *bt;

@end

@implementation MemViewController

-(void)viewWillAppear:(BOOL)animated{

    [super viewWillAppear:animated];
    
    self.navigationController.navigationBar.hidden = YES;
}

//-(void)viewWillDisappear:(BOOL)animated{
//
//    [super viewWillDisappear:animated];
//    
//    self.navigationController.navigationBar.hidden = NO;
//}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //设置背景图片
    _img = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-self.tabBarController.tabBar.frame.size.height)];
    
    _img.image = [UIImage imageNamed:@"IMG_0112.JPG"];
    _img.userInteractionEnabled = YES;
    [self.view addSubview:_img];
    
    [self createButton];
    [self createTable];
    
}



-(void)createButton{
    
    _bt = [[UIButton alloc]initWithFrame:CGRectMake((self.view.frame.size.width -200)/2, 290, 200, 40)];
    
    [_bt setTitle:@"点击" forState:UIControlStateNormal];
    [_bt setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    _bt.layer.cornerRadius = 10;
    _bt.layer.masksToBounds = YES;
    _bt.backgroundColor = [UIColor orangeColor];
    [_bt addTarget:self action:@selector(clickBt) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_bt];
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{

    if([scrollView isEqual:_table]){
    
        if(_table.contentOffset.y > -114){
        
            _bt.hidden = YES;
        }
        else{
        
            _bt.hidden = NO;
        }
    }
}

-(void)clickBt{

    NSLog(@"1111");
}

-(void)createTable{

    _table = [[UITableView alloc]initWithFrame:CGRectMake(0, 100+64+self.tabBarController.tabBar.frame.size.height, self.view.frame.size.width, self.view.frame.size.height-100-64-self.tabBarController.tabBar.frame.size.height)];
    
    _table.contentInset =UIEdgeInsetsMake(100, 0, 0, 0);
    _table.backgroundColor = [UIColor clearColor];
    
    _table.dataSource = self;
    _table.delegate   = self;
    
    [_img addSubview:_table];
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return 50;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return 7;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"aa"];
    
    if(!cell){
    
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"aa"];
    }
    
    cell.imageView.image = [UIImage imageNamed:@""];
    cell.textLabel.text = @"aa";
    
    return cell;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
